const baseUrl = 'http://123.57.90.137:4325';
const token = uni.getStorageSync('token')


function request(url, method = 'GET', data = {}, withToken = true) {
	return new Promise((resolve, reject) => {
		let header = {};
		if (withToken) {
			header['token'] = token
			console.log(header)
		}

		uni.request({
			url: baseUrl + url,
			method: method,
			header: header, // 使用修改后的header对象
			data: data,
			success: res => {
				// 这里可以根据实际需求处理res.data
				resolve(res);
			},
			fail: err => {
				// 处理请求失败的情况
				reject(err);
			}
		});
	});
}
export default request;